customproperty: Don't rely on querying style property
authorBenjamin Otte <otte@redhat.com>
Tue, 27 Mar 2012 03:00:35 +0000 (05:00 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 17 Apr 2012 06:59:12 +0000 (08:59 +0200)
This way, we can remove type madness from GtkCssStyleProperty later.

gtk/gtkcsscustomproperty.c

index 28355dccfad20b7374a58b928c49f352714b12f0..fd53b859b75eb87b3d4ba8790e7e9c920904f601 100644 (file)
 
 G_DEFINE_TYPE (GtkCssCustomProperty, _gtk_css_custom_property, GTK_TYPE_CSS_STYLE_PROPERTY)
 
+static GType
+gtk_css_custom_property_get_specified_type (GParamSpec *pspec)
+{
+  if (pspec->value_type == GDK_TYPE_RGBA ||
+      pspec->value_type == GDK_TYPE_COLOR)
+    return GTK_TYPE_SYMBOLIC_COLOR;
+  else
+    return pspec->value_type;
+}
+
 static GtkCssValue *
 gtk_css_custom_property_parse_value (GtkStyleProperty *property,
                                      GtkCssParser     *parser,
@@ -56,8 +66,7 @@ gtk_css_custom_property_parse_value (GtkStyleProperty *property,
     }
   else
     {
-      GtkCssStyleProperty *style = GTK_CSS_STYLE_PROPERTY (property);
-      g_value_init (&value, _gtk_css_style_property_get_specified_type (style));
+      g_value_init (&value, gtk_css_custom_property_get_specified_type (custom->pspec));
 
       success = _gtk_css_style_parse_value (&value, parser, base);
     }